package com.dick.base.parameter;

import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Data
public class RollAddParameter {

    @Valid
    private RollInfo info;

    @Valid
    @NotEmpty(message = "请填写卷数据")
    private List<Roll> rolls = new ArrayList<>();

    @Data
    public static class RollInfo {
        /**
         * 发货单位，32字符串
         */
        @Size(max = 32, message = "'发货单位'不能超过32字符串长度")
        private String supplyCompany;
        /**
         * 到货车辆，32字符串
         */
        @Size(max = 32, message = "'到货车辆'不能超过32字符串长度")
        private String supplyTruck;
        /**
         * 价格，元/kg
         */
        @NotNull(message = "请输入单价")
        @DecimalMin(value = "0", message = "价格不能低于0")
        private BigDecimal price;
        /**
         * 总价，元
         */
        @DecimalMin(value = "0", message = "总价不能低于0")
        private BigDecimal totalPrice;
        /**
         * 进货日期
         */
        private String supplyDate;
    }

    @Data
    public static class Roll {

        /**
         * 批号，长度限制32
         */
        @NotEmpty(message = "请输入批号")
        @Size(max = 32, message = "批号不能超过32个字符长度")
        private String batchNumber;
        /**
         * 名称，长度限制0~32
         */
        @NotEmpty(message = "请输入品名")
        @Size(max = 32, message = "品名不能超过32个字符长度")
        private String name;
        /**
         * 初始重量，int类型，单位：公斤
         */
        @NotNull(message = "请输入净重")
        @DecimalMin(value = "0", message = "重量不能低于0")
        private BigDecimal initWeight;
        /**
         * 材质，长度限制0~32
         */
        @NotEmpty(message = "请输入‘材质’")
        @Size(max = 32, message = "'材质'不能超过32字符长度")
        private String material;
        /**
         * 厚度，长度限制0~32，单位mm
         */
        @NotEmpty(message = "请输入‘厚度’")
        @Size(max = 32, message = "'厚度'不能超过32字符长度")
        private String thickness;
        /**
         * 宽度，int类型，单位mm
         */
        @NotNull(message = "请输入'宽度'")
        @Min(value = 0, message = "'宽度'必须大于0毫米")
        private Integer width;
    }

}
